package IO流.Reader;

import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

@SuppressWarnings("all")
public class BufferedReader01 {

    @Test
    public void bufferReader001() throws IOException {
        String filePath = "src/main/java/IO流/Reader/hello.txt";
        BufferedReader bufferedReader = null;
        try {

            bufferedReader = new BufferedReader(new FileReader(filePath));
            String line;
            //按行读取, 从字符输入流读取文本，缓冲字符，以提高字符，数组和行的高效读取，如果返回为null，代表已到达流的末尾
            while ((line = bufferedReader.readLine()) != null){
                System.out.println(line);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            bufferedReader.close();
        }
    }
}
